var prefix = api + "/gen/dsconf";
var oper = getQueryString('oper')
var id = getQueryString('id')
$(function () {
	$('#oper').val(oper)
	if (oper === 'edit') {
		dataSourceDetail(id)
	}
})

function dataSourceDetail(id){
	$.operate.get(api + '/gen/dsconf/' + id, function (res) {
		res.data.oper = oper
        res.data.password = ''
		applyDrawing('#editForm',res.data)
	}, false)
}

$("#editForm").validate({
	onkeyup: false,
	rules:{
		name:{
			required:true
		},
		url:{
			required:true,
		},
		username:{
			required:true
		},
        password:{
			required:true
		},
	},
    focusCleanup: true
});

function submitHandler() {
    if ($.validate.form()) {
    	$.common.ajaxCommitForm($('#editForm'),false);
    	return false;
    }
}